//
//  MessageTabViewController.m
//  IceBreaker
//
//  Created by 老焦 on 12-10-20.
//  Copyright (c) 2012年 NDS. All rights reserved.
//

#import "MessageTabViewController.h"
#import "CustomMessageCell.h"

@interface MessageTabViewController ()

@end

@implementation MessageTabViewController

-(id) init {
    self = [super initWithNibName: nil bundle: nil];
    if (self) {
        self.title = NSLocalizedStringFromTable(@"Tab message", @"Localizable", @"Message");
        
        UITabBarItem *msgTab = [self tabBarItem];
        UIImage *msgImage = [UIImage imageNamed: @"message.png"];
        msgTab.image = msgImage;
        msgTab.title = NSLocalizedStringFromTable(@"Tab message", @"Localizable", @"Message");
        self.tabBarItem = msgTab;
    }
    return self;
}

- (id)initWithStyle:(UITableViewStyle)style {
    return [self init];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"CustomMessageCellIdentifier";
    CustomMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[CustomMessageCell alloc] initWithHeadImg: [UIImage imageNamed: @"head.png"]
                                                      name: @"Legend"
                                                  distance: 333.3
                                                  sendTime: [NSDate date]
                                                  msgState: 1
                                                msgContent: @"Just a message for test!"
                                           reuseIdentifier: CellIdentifier] autorelease];
        
        cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
        cell.selectedBackgroundView.backgroundColor = [UIColor clearColor];
    }
    
    return cell;
}

#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}

-(CGFloat) tableView: (UITableView *)tableView heightForRowAtIndexPath: (NSIndexPath *)indexPath {
    UITableViewCell *cell = [self tableView: tableView cellForRowAtIndexPath: indexPath];
    return cell.frame.size.height;
}

@end
